//import './assets/main.css'	

import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

/**
 * 引入ElementPlus
 */
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css'

 /**
  * 引入axios,封装好的
  */
import instance from './uitls/http.js' 

/**
 * 引入阿里图库
 */
import '../public/icon/iconfont.css'

const app = createApp(App)

/**
 * 注册ElementPlus
 */
app.use(ElementPlus)
/**
 * 注册axios
 */
app.config.globalProperties.$axios = instance

/**
 * 配置路由守卫
 */
router.beforeEach((to, from, next)=>{
	let token=sessionStorage.getItem("user");
	if(to.path !== '/' && to.path !== '/register' && token==null) {
		next('/'); // 重定向到登录页面
	}else if(to.path=='/' && token!=null ){
		next('/home'); // 已经登录过
	}else {
		next(); // 继续导航到下一个路由
	}
})

app.use(router)
app.mount('#app')
